const Response = require("../../class/Response");
WSS.on('close', (thisClient, code, reason)=>{
    if (thisClient.userType != 'bds'){return;}
    // 注销该bds所有玩家
    delete WSS.clientsManager.onlinePlayers[thisClient?.bds?.uuid];

    // 更新客户端的在线玩家信息(一共四处, bds连接断连，玩家登录退出)
    WSS.clientsManager.broadcastJson(new Response().setUrl('/bds/onlineInfo')
        .setSourceId(thisClient.id)
        .setSourceBdsUuid(thisClient.bds.uuid)
        .setSourceBdsServerName(thisClient.name)
        .setStatusCode(0)
        .setStatusMessage("更新客户端的在线玩家信息")
        .setData({
            onlineClientsInfo: WSS.clientsManager.getOnlineClientsInfo(),
            onlinePlayersInfo: WSS.clientsManager.onlinePlayers
        })
    );
});